import { _decorator, Component, Graphics, PolygonCollider2D } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('cutObj')
export class cutObj extends Component {

    protected onLoad(): void {
        this.refresh()
    }

    start() {

    }

    update(deltaTime: number) {

    }

    refresh() {
        const points = this.getComponent(PolygonCollider2D).points;
        const ctx = this.getComponent(Graphics);
        ctx.clear();
        const len = points.length;
        ctx.moveTo(points[len - 1].x, points[len - 1].y);
        for (let i = 0; i < points.length; i++) {
            ctx.lineTo(points[i].x, points[i].y);
        }
        ctx.fill();
    }
}


